package com.google.android.gms.internal;

import java.io.IOException;

public final class zzbg extends zzflm<zzbg> {
    public byte[] zzgk = null;
    public byte[][] zzgp = zzflv.zzpwd;
    private Integer zzgq;
    public Integer zzgr;

    public zzbg() {
        this.zzpnr = -1;
    }

    /* access modifiers changed from: private */
    /* renamed from: zzd */
    public final zzbg zza(zzflj zzflj) throws IOException {
        int i;
        while (true) {
            int zzcxx = zzflj.zzcxx();
            if (zzcxx == 0) {
                return this;
            }
            if (zzcxx == 10) {
                int zzb = zzflv.zzb(zzflj, 10);
                int length = this.zzgp == null ? 0 : this.zzgp.length;
                byte[][] bArr = new byte[(zzb + length)][];
                if (length != 0) {
                    System.arraycopy(this.zzgp, 0, bArr, 0, length);
                }
                while (length < bArr.length - 1) {
                    bArr[length] = zzflj.readBytes();
                    zzflj.zzcxx();
                    length++;
                }
                bArr[length] = zzflj.readBytes();
                this.zzgp = bArr;
            } else if (zzcxx == 18) {
                this.zzgk = zzflj.readBytes();
            } else if (zzcxx == 24) {
                i = zzflj.getPosition();
                int zzcym = zzflj.zzcym();
                switch (zzcym) {
                    case 0:
                    case 1:
                    case 2:
                        this.zzgq = Integer.valueOf(zzcym);
                        break;
                    default:
                        StringBuilder sb = new StringBuilder(41);
                        sb.append(zzcym);
                        sb.append(" is not a valid enum ProtoName");
                        throw new IllegalArgumentException(sb.toString());
                }
            } else if (zzcxx == 32) {
                i = zzflj.getPosition();
                try {
                    int zzcym2 = zzflj.zzcym();
                    switch (zzcym2) {
                        case 0:
                        case 1:
                        case 2:
                        case 3:
                            this.zzgr = Integer.valueOf(zzcym2);
                            break;
                        default:
                            StringBuilder sb2 = new StringBuilder(48);
                            sb2.append(zzcym2);
                            sb2.append(" is not a valid enum EncryptionMethod");
                            throw new IllegalArgumentException(sb2.toString());
                    }
                } catch (IllegalArgumentException unused) {
                    zzflj.zzmw(i);
                    zza(zzflj, zzcxx);
                }
            } else if (!super.zza(zzflj, zzcxx)) {
                return this;
            }
        }
    }

    public final void zza(zzflk zzflk) throws IOException {
        if (this.zzgp != null && this.zzgp.length > 0) {
            for (byte[] bArr : this.zzgp) {
                if (bArr != null) {
                    zzflk.zzc(1, bArr);
                }
            }
        }
        if (this.zzgk != null) {
            zzflk.zzc(2, this.zzgk);
        }
        if (this.zzgq != null) {
            zzflk.zzad(3, this.zzgq.intValue());
        }
        if (this.zzgr != null) {
            zzflk.zzad(4, this.zzgr.intValue());
        }
        super.zza(zzflk);
    }

    /* access modifiers changed from: protected */
    public final int zzq() {
        int zzq = super.zzq();
        if (this.zzgp != null && this.zzgp.length > 0) {
            int i = 0;
            int i2 = 0;
            for (byte[] bArr : this.zzgp) {
                if (bArr != null) {
                    i2++;
                    i += zzflk.zzbg(bArr);
                }
            }
            zzq = zzq + i + (1 * i2);
        }
        if (this.zzgk != null) {
            zzq += zzflk.zzd(2, this.zzgk);
        }
        if (this.zzgq != null) {
            zzq += zzflk.zzag(3, this.zzgq.intValue());
        }
        return this.zzgr != null ? zzq + zzflk.zzag(4, this.zzgr.intValue()) : zzq;
    }
}
